package name.marz.to.go.ahg.mhbk.executer;

import name.marz.to.go.ahg.core.checker.DocumentChecker;
import name.marz.to.go.ahg.core.exception.CannotLoginException;
import name.marz.to.go.ahg.core.exception.UnknownClientException;
import name.marz.to.go.ahg.core.exception.UserProcessException;

import org.jsoup.nodes.Document;

public class MHBKUserNumberChecker implements DocumentChecker {
	private String ERR_UNCORRECT_INPUT = "EMFk93";
	@Override
	public void check(Document doc) throws UserProcessException {
		// 入力内容が正しくありません
		if ( doc.body().html().contains(ERR_UNCORRECT_INPUT)) {
			CannotLoginException cle = new CannotLoginException(
					doc.body().getElementsContainingOwnText(ERR_UNCORRECT_INPUT).first().text()
					);
			cle.setDocument(doc);
			throw cle;
		}
		// 端末未登録チェック
		if ( doc.body().html().contains("合言葉確認")) {
			UnknownClientException uce = new UnknownClientException();
			uce.setDocument(doc);
			throw uce;
		}
		return;
	}
}